#! /usr/bin/env python

import Reactor
import time
import sys

def call_back(args):
    print Reactor.get_current(), args

class call_back_class:
    def call_back(self,args):
        print Reactor.get_current(), args

def test_timer_queue():
    timers = Reactor.Timer_Queue()
    timers.add_timer(1, call_back, "hello")
    c = call_back_class()
    timers.add_timer(2, c.call_back, "World")
    time.sleep(1.1)
    timers.process()
    time.sleep(1.1)
    timers.process()


class test_handler(Reactor.Handler):
    def __init__(self, reactor):
        Reactor.Handler.__init__(self,reactor)
        self.fd = sys.stdin
    
    def handle_input(self):
        print sys.stdin.read(1)
        return 0

def test_reactor():
    r = Reactor.Reactor()
    h = test_handler(r)
    r.register_handler(h,Reactor.READ_MASK)
    r.run()

if __name__ == "__main__":
    test_timer_queue()
    test_reactor()

